// custom-tab-bar/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    active: 0,
    tabbarArr:[
      {
        "pagePath":"/pages/home/home",
        "text":"首页",
        "icon":"wap-home-o"
      },
      {
        "pagePath":"/pages/topic/topic",
        "text":"专题",
        "icon":"label-o"
      },
      {
        "pagePath":"/pages/type/type",
        "text":"分类",
        "icon":"apps-o"
      },
      {
        "pagePath":"/pages/cart/cart",
        "text":"购物车",
        "icon":"cart-o"
      },
      {
        "pagePath":"/pages/user/user",
        "text":"我的",
        "icon":"user-o"
      },
    ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onChange(event) {
      // event.detail 的值为当前选中项的索引
      this.setData({
        active: event.detail
      });
      // 拿到id
      let id=event.detail;
      // console.log(id);
      // 拿到路由
      var path=this.data.tabbarArr[id].pagePath;
      // console.log(path);
      // 跳转路由
      wx:wx.switchTab({
        url: path
      })
    },
  }
})